import {id_define} from "@/api/api";
import router from "@/router";

export const role_filter = (role) => {
    const map = ["", "admin", "teacher", "student"];
    id_define().then(res => {
        console.log(map[res.data.data.role]);
        if (map[res.data.data.role] !== role){
            if(map[res.data.data.role] !== null){
                router.replace("/login")
            }else{
                router.replace("/" + map[res.data.data.role])
            }
        }
    }, error => {
        console.log(error)
        router.replace("/login")
    })
}